function [output] = object(x, SIM,weight) 
global num_firm T_sim S T n_theta sigma beta n_tran tau mktfe search country_num phi
% ad+1_mean ad+1_std  price_mean  price_std  sales_mean sales_std

mom_true = [2.043844 5.463639 3.549523 1.422837]; %annual price_mean price_std sales1_mean sales1_std quan1_mean quan1_std
% mom_true = [2.043844 0.5463639 3.549523 1.422837]; %annual

ave_theta = exp(x(1));
h_eps =   exp(x(2)); % positive and bigger than h_theta
if h_eps>0.3988
    h_theta =   exp(x(3))+ exp(x(2)); % positive,0.3987
else
    h_theta = 0.3988 + exp(x(3));
end
wc = -2.41*h_theta./phi-1; %1*104 1/variance for each country, ave_theta>max(-phi/2.41) =0.4078 to ensure positive wc
%rho = exp(x(3));
%h_eps = 0.7;
%delta = normcdf(x(4));% [0,1]
delta = 0.02;
cost = exp(x(4)); % positive
gamma = 0;
disp('x1 x2 x3 x4')
disp(x)
step = 1;
learn = 1;
[mom_stack] = simulate(ave_theta, h_theta, h_eps, delta, cost,gamma,wc, SIM, step,learn);
%% weighting matrix>> to be added
mom_stack_ave = nanmean(mom_stack,2);
weighting = 1000000;
%mom_stack_ave = mom_stack_ave(1:4)
output = (mom_true-mom_stack_ave')*weighting*(mom_true'-mom_stack_ave);
disp(' mean_price_overtime   std_price_overtime    mean_sales   std_sales');
disp(mom_stack_ave');
end

